﻿using System.Configuration;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using Eff.Extensions;
using Redmine.Core.Entities;

namespace Redmine.Core.UnitOfWork
{
    public class DbDataContext : DbContext
    {
        public static readonly string ConStrKey = ConfigurationManager.AppSettings["Mode"].AsString("dev");
        private static readonly string ConStr = ConfigurationManager.ConnectionStrings[ConStrKey].ConnectionString;
        public DbSet<User> Users { get; set; }
        public DbSet<Member> Members { get; set; }
        public DbSet<Setting> Settings { get; set; }
        public DbDataContext()
            : base(ConStr)
        {

        }
        internal void Commit()
        {
            base.SaveChanges();
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
        }

    }
}
